package com.cby.android.sample.activities

import android.graphics.Color
import androidx.appcompat.widget.Toolbar
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.cby.android.library.base.BaseActivity
import com.cby.android.sample.R
import com.cby.android.sample.adapter.RollMoreAdapter
import com.scwang.smart.refresh.layout.api.RefreshLayout
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration

/**
 * @description: MoreActivity
 *
 * @author ChenBaoyang
 * @date 4/23/21 10:34
 */
class RollMoreActivity : BaseActivity(){

    private val refreshLayout: RefreshLayout by lazy { findViewById(R.id.refreshLayout) }
    private val recyclerView: RecyclerView by lazy { findViewById(R.id.recycler_view) }

    override fun getLayoutId() = R.layout.roll_activity_more

    override fun onViewInit() {
        title = "工具合集"
        recyclerView.isEnabled = false
        // 关闭上拉刷新
        refreshLayout.setEnableLoadMore(false)
        // 关闭下拉刷新
        refreshLayout.setEnableRefresh(false)
        val linearLayoutManager =
            LinearLayoutManager(
                this,
                LinearLayoutManager.VERTICAL,
                false
            )
        recyclerView.layoutManager = linearLayoutManager
        recyclerView.itemAnimator = DefaultItemAnimator()
        recyclerView.addItemDecoration(
            HorizontalDividerItemDecoration.Builder(this).color(Color.LTGRAY)
                .build()
        )
    }

    override fun onDataInit() {
        val datas = mutableListOf<String>()
        datas.add("便民服务")
        datas.add("生活阅读")
        datas.add("休闲旅游")
        datas.add("工具集合")
        val adapter = RollMoreAdapter()
        recyclerView.adapter = adapter
        adapter.setNewData(datas)
    }
}